package demo01;
//提莫攻击
class Solution {
    public int findPoisonedDuration(int[] timeSeries, int duration) {
        int ret = 0;
        int n = timeSeries.length;
        for(int i = 0;i < n;i++){
            if(i == n-1){
                ret += duration;
                break;
            }
            int x = timeSeries[i + 1] - timeSeries[i];
            if(x < duration){
                ret = ret + x;
            }else{
                ret = ret + duration;
            }
        }
        return ret;
    }
}